<div class="container">

    <div class="form-horizontal">
        <div class="control-group">
            <label class="control-label">#</label>
            <div class="controls">
                <input type="text" class="span2 input-block-level" value="<?=$consulta['idconsulta']?>" disabled>
            </div>
        </div>

        <div class="control-group">
            <label class="control-label">Proveedor</label>
            <div class="controls">
                <input type="text" class="span6 input-block-level" value="<?=$consulta['proveedor']['nombre']?>" disabled>
            </div>
        </div>

        <div class="control-group">
            <label class="control-label">Fecha</label>
            <div class="controls">
                <input type="text" class="span2 input-block-level" value="<?=  substr($consulta['fecha'], 8, 2).'/'.  substr($consulta['fecha'], 5, 2).'/'.  substr($consulta['fecha'], 0, 4)?>" disabled>
            </div>
        </div>

        <div class="control-group">
            <label class="control-label">Moneda</label>
            <div class="controls">
                <input type="text" class="span2 input-block-level" value="<?=$consulta['moneda']['moneda']?>" disabled>
            </div>
        </div>

        <div class="control-group">
            <label class="control-label">Observaciones</label>
            <div class="controls">
                <textarea class="span6 input-block-level" disabled><?=$consulta['observaciones']?></textarea>
            </div>
        </div>
    </div>
    
    <?php echo validation_errors("<div class='alert alert-danger'>", "</div>"); ?>
    
    <form class="form-inline" method="post">
        <div class="row">
            <input name="cantidad" id="cantidad" type="text" class="span2 input-block-level" placeholder="Cantidad">
            <select name="articulo" class="span4 chosen">
                <?php foreach($articulos as $articulo) { ?>
                <option value="<?=$articulo['idArticulo']?>"><?=$articulo['producto']['nombre'].' '.$articulo['codigo'].' '.$articulo['marca']['nombre']?></option>
                <?php } ?>
            </select>
            <input name="precio" type="text" class="span2 input-block-level" placeholder="Precio">
            <input name="entrega" maxlength="100" type="text" class="span2 input-block-level" placeholder="Entrega">
            <textarea name="observaciones" type="text" class="span3 input-block-level" placeholder="Observaciones"></textarea>
            <button type="submit" class="btn btn-primary">Agregar</button>
        </div>
    </form>
    
    <div class="text-center">
        <a href="/consultas/">
            <button type="submit" class="btn btn-primary">Finalizar</button>
        </a>
    </div>
    
    <br>
    
    <table class="table table-bordered table-striped">
        <thead>
            <tr>
                <th>Cantidad</th>
                <th>Artículo</th>
                <th>Marca</th>
                <th>Precio</th>
                <th>Entrega</th>
                <th>Observaciones</th>
                <th></th>
            </tr>
        </thead>
        <tbody>
            <?php foreach($items as $item) { ?>
            <tr>
                <td><?=$item['cantidad']?></td>
                <td><?=$item['articulo']['producto']['nombre'].' '.$item['articulo']['codigo']?></td>
                <td><?=$item['articulo']['marca']['nombre']?></td>
                <td><?=number_format($item['precio'], 2)?></td>
                <td><?=$item['entrega']?></td>
                <td><?=$item['observaciones']?></td>
                <td><a href="/consultas/update_item/<?=$item['iditemsconsulta']?>"><i class="icon-edit"></i></a> <a href="/consultas/borrar_item/<?=$consulta['idconsulta']?>/<?=$item['iditemsconsulta']?>"><i class="icon-remove"></i></a></td>
            </tr>
            <?php } ?>
        </tbody>
    </table>

    <div class="text-center">
        <a href="/consultas/">
            <button type="submit" class="btn btn-primary">Finalizar</button>
        </a>
    </div>
    
</div>

<script type="text/javascript">
    $(document).ready(function() {
        $("#cantidad").focus();
        $(".chosen").chosen();
    });
</script>